﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AdminLogin.aspx.cs" Inherits="AdminLogin" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Administrator</title>
    <%--<link href="CSS/loginstyle.css" rel="stylesheet" type="text/css" />--%>
    <script src="JS/Plugins/jquery-1.9.1.js" type="text/javascript"></script>

    <link href="CSS/AdminPage.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    #choice
    {
        float:left;
    }
    </style>
    <link rel="stylesheet" type="text/css" href="CSS/adminHeaderDesign.css" />
    <script type="text/javascript">
        function checkAdminlogin() {

            var jData = {};


            jData.person = $('input[name=myradiobutton]:radio:checked').val();
            // alert(jData.person);


            jData.userName = $('#login').val();
            jData.password = $('#password').val();
            //alert('hai');
            // alert(jData.userName);
            $.ajax({
                type: "POST",
                url: "LoginService.svc/AdminLogin",
                data: JSON.stringify(jData),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    var Result = eval('(' + response.d + ')');

                    alert(Result["Message"]);

                    var loginperson = Result["PersonName"];
                    alert(loginperson);
                    if (Result["Person"] == "Admin") {

                        //Response.Redirect("NewDashboard.aspx?userid=" + loginperson + "");
                        window.location = "NewDashboard.aspx?userid=" + loginperson + "";
                        // moreDetails.aspx?proid=' + data.binding[start].ProductID + '
                    }
                    else if (Result["Person"] == "SalesPerson") {

                        // Response.Redirect("SalesUserDashboard.aspx?userid=" + loginperson + "");
                        window.location = "SalesUserDashboard.aspx?userid=" + loginperson + "";

                    }
                },
                failure: function (msg) {
                    alert(msg);
                },
                error: function (jqXHR, exception) {
                    if (jqXHR.status === 0) {
                        alert('Not connect.\n Verify Network.');
                    } else if (jqXHR.status == 404) {
                        alert('Requested page not found. [404]');
                    } else if (jqXHR.status == 500) {
                        alert('Internal Server Error [500].');
                    } else if (exception === 'parsererror') {
                        alert('Requested JSON parse failed.');
                    } else if (exception === 'timeout') {
                        alert('Time out error.');
                    } else if (exception === 'abort') {
                        alert('Ajax request aborted.');
                    } else {
                        alert('Uncaught Error.\n' + jqXHR.responseText);
                    }
                }

            });

            return false;
        }
    </script>
    <script src="JS/jquery.validate.js" type="text/javascript"></script>
    <script src="JS/jquery.validation.functions.js" type="text/javascript"></script>
    <script src="JS/Shi-1.3.js" type="text/javascript"></script>
    <link href="CSS/jquery.validate.css" rel="stylesheet" type="text/css" />
    <link href="CSS/style33.css" rel="stylesheet" type="text/css" />
</head>
<body>
    
    <%--<div class="login">
        <div class="c1">
            <p>
                &nbsp;</p>
            <p>
                &nbsp;</p>
            <p>
                &nbsp;</p>
            <p>
                &nbsp;</p>
            <form id="Form1" runat="server">
            <asp:RadioButtonList ID="radiolist1" runat="server">
                <asp:ListItem Selected="true" Value="1">Admin</asp:ListItem>
                <asp:ListItem Value="2">Salesuser</asp:ListItem>
            </asp:RadioButtonList>
            <br />
            <br />
            <br />
            <label>
                Username</label>
            <input type="text" name="login" id="login" runat="server" placeholder="Administrator"><br>
            <label>
                Password</label>
            <input type="password" name="password" id="password" runat="server" placeholder="password"><br>
            <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
            </form>
        </div>
    </div>--%>

    <section class="container">
    <div class="login">
      <h1>Login to Ecommerce Application</h1>
      <%--<form method="post" action="index.html">
        <p><input type="text" name="login" value="" placeholder="Username or Email"></p>
        <p><input type="password" name="password" value="" placeholder="Password"></p>
        <p class="remember_me">
          <label>
            <input type="checkbox" name="remember_me" id="remember_me">
            Remember me on this computer
          </label>
        </p>
        <p class="submit"><input type="submit" name="commit" value="Login"></p>
      </form>--%>

      <form id="Form1" runat="server">
            <asp:RadioButtonList ID="radiolist1" runat="server">
                <asp:ListItem Selected="true" Value="1">Admin</asp:ListItem>
                <asp:ListItem Value="2">Salesuser</asp:ListItem>
            </asp:RadioButtonList>
            <br />
            <br />
            <br />
            <label>
                Username</label>
               <asp:TextBox ID="login" runat="server"></asp:TextBox>
            <%--<input type="text" name="login" id="login" runat="server" placeholder="Administrator"><br>--%>
            <label>
                Password</label>
                <asp:TextBox ID="password" TextMode="Password" runat="server"></asp:TextBox>
            <%--<input type="password" name="password" id="password" runat="server" placeholder="password"><br>--%>
            <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
            </form>
    </div>

    <div class="login-help">
      <p>Forgot your password? <a href="#">Click here to reset it</a>.</p>
    </div>
  </section>


</body>
</html>
